#ifndef __DS18B20_H__
#define __DS18B20_H__

#include "common.h"
#include "1wire.h"

#ifdef _STM32F10X
#  include <stm32f10x_gpio.h>
#endif // _STM32F10X

typedef struct _DS18B20
{
	POneWireBusCtx pBusCtx;
	OneWireAddr    rom;
} DS18B20;

// ---------------------------------------------------------------------------
// method declarations
// ---------------------------------------------------------------------------

// Initialize a DS18B20 chip by specifying 1wire IO bus context and chip rom
// rom=0 when there is a single device on the bus
void DS18B20_InitConfiguration(DS18B20* chip, POneWireBusCtx pBusCtx, OneWireAddr rom);

// read the temperature from a DS18B20 chip, the temperature value is in 0.1C
int16_t DS18B20_read(DS18B20* chip);

#endif // __DS18B20_H__
